<?php if(!defined('FRAME')) exit('No direct script access allowed');
/**
 * 视图层
 * @author wisoch@hotmail.com
 *
 */

include FRAME . '/smarty/Smarty.class.php';
class View {
	public static $_instance;
	public $smarty;
	public function __construct ($cache = 0) {
		$config = Config::Instance();
		$tmp = $config->get('runtime.tmp_dir');

		$this->smarty = new Smarty();
		$this->smarty->setTemplateDir(SERVER_PATH.'/template/')
					   ->setCompileDir($tmp . DS . SERVER_NAME . DS . 'smarty/compile_c' . DS)
					   ->setCacheDir($tmp . DS . SERVER_NAME . DS . 'smarty/cache' . DS)
					   ->addPluginsDir(SERVER_PATH.'/extend/')
					   ->setCaching((boolean) $cache);
		if($cache) $this->smarty->cache_lifetime = $cache;
		$this->smarty->error_reporting = E_ALL & ~E_NOTICE;
	}
	public static function Instance($cache = 0) {
        if( ! (self::$_instance instanceof self) ) {
            self::$_instance = new self($cache);
        }
        return self::$_instance;
    }
}
?>